<script setup lang="ts">
import { computed, onMounted, ref } from 'vue'
import { getIcon } from "@/api/assets/assets";

// 使用 import 导入图片资源
// import imgCloudClose from '@/assets/cloud_close 1.png'
// import imgFolderMinus from '@/assets/folder_minus 1.png'
// import imgFolderOpen from '@/assets/folder_open 1.png'
// import imgWindowCheck from '@/assets/window_check 1.png'

const imgFolderOpen = ref<string | undefined>(undefined)
const imgCloudClose = ref<string | undefined>(undefined)
const imgFolderMinus = ref<string | undefined>(undefined)
const imgWindowCheck = ref<string | undefined>(undefined)

const fetchIcon = async () => {
  try {
    const data = await getIcon([
      'cloud_close 1.png',
      'folder_minus 1.png',
      'folder_open 1.png',
      'window_check 1.png',
    ]);
    imgFolderOpen.value = data['folder_open 1.png'];
    imgCloudClose.value = data['cloud_close 1.png'];
    imgFolderMinus.value = data['folder_minus 1.png'];
    imgWindowCheck.value = data['window_check 1.png'];
  }
  catch (error) {
    console.error('API 调用错误:', error);
  }
};

onMounted(() => {
  fetchIcon();
});

const cards = computed(() =>
  [
    {
      image: imgFolderOpen.value,
      alt: 'Folder',
      title: '资源管理',
      text: '支持个人和团队应用和数据的创建，提升创新效率，帮助学生和团队快速实现创意，简化开发过程。',
    },
    {
      image: imgCloudClose.value,
      alt: 'Cloud',
      title: '资源管理',
      text: '支持个人和团队应用和数据的创建，提升创新效率，帮助学生和团队快速实现创意，简化开发过程。',
    },
    {
      image: imgFolderMinus.value,
      alt: 'Folder',
      title: '资源管理',
      text: '支持个人和团队应用和数据的创建，提升创新效率，帮助学生和团队快速实现创意，简化开发过程。',
    },
    {
      image: imgWindowCheck.value,
      alt: 'Check',
      title: '资源管理',
      text: '支持个人和团队应用和数据的创建，提升创新效率，帮助学生和团队快速实现创意，简化开发过程。',
    },
  ],
)
</script>

<template>
  <div class="team-collaboration-section">
    <div class="section-header">
      <div class="line left-line" />
      <h2 class="title">
        高效打造团队协作空间
      </h2>
      <div class="line right-line" />
    </div>
    <div class="description">
      <p>高效团队协作空间：支持应用开发、数据管理、任务分配和知识积累，全面提升团队合作效率。</p>
    </div>
    <div class="card-container">
      <div v-for="(card, index) in cards" :key="index" class="card">
        <div class="card-image">
          <img :src="card.image" :alt="card.alt">
        </div>
        <div class="card-content">
          <h3 class="card-title">
            {{ card.title }}
          </h3>
          <p class="card-text">
            {{ card.text }}
          </p>
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped>
.team-collaboration-section {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.line {
  width: 107px;
  height: 0;
  border: 1px solid;
  opacity: 1;
}

.left-line {
  border-image-source: linear-gradient(270deg, rgba(102, 102, 102, 0) 0%, #000000 100%);
  border-image-slice: 1;
  transform: rotate(180deg);
  margin-right: 20px;
  margin-top: 20px;
}

.right-line {
  border-image-source: linear-gradient(270deg, #000000 0%, rgba(102, 102, 102, 0) 100%);
  border-image-slice: 1;
  margin-left: 20px;
  transform: rotate(180deg);
  margin-top: 20px;
}

.title {
  font-family: 'Alimama ShuHeiTi', sans-serif;
  font-size: 44px;
  font-weight: 700;
  line-height: 34px;
  color: #3f3f3f;
  white-space: nowrap;
}

.description {
  font-family: 'Alibaba PuHuiTi', sans-serif;
  font-size: 16px;
  font-weight: 400;
  line-height: 22px;
  color: #86869f;
  text-align: center;
  width: 800px;
  margin-top: 10px;
  margin-bottom: 50px;
}

.card-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 40px;
}

.card {
  width: 590px;
  height: 245px;
  background: linear-gradient(90.32deg, #e1eeff 1.49%, #eaf9ff 101.03%);
  border: 1px solid #ffffff;
  border-radius: 12px;
  display: flex;
  align-items: center;
  padding: 20px;
  transition: background 0.3s, color 0.3s, border-color 0.3s;
}

.card-image {
  width: 56px;
  height: 56px;
  margin-right: 20px;
  margin-left: 20px;
  transition: filter 0.3s;
}

.card-image img {
  filter: invert(37%) sepia(96%) saturate(3772%) hue-rotate(190deg) brightness(96%) contrast(105%);
}

.card-content {
  flex: 1;
}

.card-title {
  font-family: 'Alibaba PuHuiTi', sans-serif;
  font-size: 24px;
  font-weight: 700;
  line-height: 32.93px;
  color: #417eff;
}

.card-text {
  font-family: 'Alibaba PuHuiTi', sans-serif;
  font-size: 16px;
  font-weight: 400;
  line-height: 21.95px;
  color: #000000;
}

.card:hover {
  background: #417eff;
  border-color: #417eff;
}

.card:hover .card-title,
.card:hover .card-text {
  color: #ffffff;
}

.card:hover .card-image img {
  filter: brightness(0) invert(1);
}
</style>
